#include <condition_variable>
#include <mutex>
#include <chrono>
#include <thread>
#include <iostream>

std::condition_variable cv;
bool done;
std::mutex m;

bool wait_loop()
{
	auto const timeout = std::chrono::steady_clock::now() + std::chrono::milliseconds(3000);
	std::unique_lock<std::mutex> lk(m);
	while(!done) {
		if (cv.wait_until(lk,timeout) == std::cv_status::timeout){
			std::cout << "timeout" << std::endl;
			break;
		}
	}
	return done;
}

int main()
{
	std::thread thread1(wait_loop);
	std::cout << "main" <<std::endl;
	thread1.join();
}